package org.testis.webautomationmodule.ui.objects;

import org.testis.logging.AtofLogLevel;
import org.testis.webautomationmodule.ui.UIBehaviorDecorator;


public class UIFrame extends UIBehaviorDecorator
{

    private String[] m_pathToFrame;


    public UIFrame(String[] pathToFrame)
    {
        setPathToFrame(pathToFrame);
    }


    @Override
    protected boolean setBehavior()
    {
        String selectingFrame = "";
        try {

            for (int i = 0; i < getPathToFrame().length; i++) {
                selectingFrame = getPathToFrame()[i];
                getWebAutomationImpl().selectFrame(selectingFrame);
                putLog(" Selecting frame with id " + selectingFrame);
            }
            getWebAutomationImpl().currFramePath = m_pathToFrame;

            return true;
        } catch (Exception ex) {
            putLog(" could not select frame " + selectingFrame + " with error:" +
                   ex.getMessage(),
                   AtofLogLevel.ERROR);
            return false;
        }
    }


    public String[] getPathToFrame()
    {
        return m_pathToFrame;
    }


    public void setPathToFrame(String[] pathToFrame)
    {
        this.m_pathToFrame = pathToFrame;
    }
}

